home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
DEMONSTR
/
VLIB20.ZIP
/
DEMOPROC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-13
|
40KB
|
1,470 lines
/****************************************************************************
PROGRAM: Vlibdemo.exe
PURPOSE: To demonstrate the usage of Visualib(TM) functions.
PROVIDER: Visual Technology, Co.
P.O.Box 901-413
Kansas City, MO 64190
Tel. (219) 289-0235
Fax. (816) 746-6618
DATE: May, 1993
****************************************************************************/
#include <windows.h>
#include <stdlib.h>
#include <math.h>
#include "visualib.h"
#include "menu.h"
#include "vlibdemo.h"
#include "demoproc.h"
HINSTANCE hdllinst = 0;
int WINAPI LibMain (HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
{
if (cbHeapSize != 0)
UnlockData (0);
hdllinst = hinst;
return (1);
}
VOID WINAPI MinRoutine (int nParameter, LPSTR lpszParam2)
{
}
int WINAPI WEP (int nParameter)
{
if (nParameter == WEP_SYSTEM_EXIT) {
return (1);
}
else if (nParameter == WEP_FREE_DLL) {
return (1);
}
else {
return (1);
}
}
VOIDED Prime2D (HDC hdc, int func)
{
short i;
double x, y, a;
PenColor (hdc, VL_WHITE);
DisplayViewerFrame (hdc, VL_CURRENT);
switch (func) {
case IDM_2DPRIME_LINE:
SetViewerName (VL_CURRENT, "2D Lines");
PenColor (hdc, VL_RED);
MoveTo2D (hdc, 0, 0);
LineTo2D (hdc, 1, 1);
RLineTo2D (hdc, -2, 0);
RLineTo2D (hdc, 0, -2);
RLineTo2D (hdc, 2, 0);
RLineTo2D (hdc, 0, 2);
RMoveTo2D (hdc, 1, 1);
LineTo2D (hdc, -2, 2);
PenColor (hdc, VL_BLUE);
MoveTo2H (hdc, 1, 1, 0.5f);
LineTo2H (hdc, 0, 1, 0);
LineTo2H (hdc, 0, 0, 1);
MoveTo2H (hdc, -1, 1, 0.5f);
LineTo2H (hdc, -1, 0, 0);
LineTo2H (hdc, 0, 0, 1);
MoveTo2H (hdc, -1, -1, 0.5f);
LineTo2H (hdc, 0, -1, 0);
LineTo2H (hdc, 0, 0, 1);
MoveTo2H (hdc, 1, -1, 0.5f);
LineTo2H (hdc, 1, 0, 0);
LineTo2H (hdc, 0, 0, 1);
PenColor (hdc, VL_GREEN);
Line2D (hdc, -15, 5, 15, 5);
Line2D (hdc, -15, -5, 15, -5);
Line2D (hdc, -5, -15, -5, 15);
Line2D (hdc, 5, -15, 5, 15);
Line2D (hdc, -15, 0, 0, 15);
Line2D (hdc, 15, 0, 0, 15);
Line2D (hdc, 0, -15, 15, 0);
Line2D (hdc, 0, -15, -15, 0);
PenColor (hdc, VL_YELLOW);
Line2H (hdc, -5, 5, 0.75f, 5, 5, 0.75f);
Line2H (hdc, -5, -5, 0.75f, 5, -5, 0.75f);
Line2H (hdc, -5, -5, 0.75f, -5, 5, 0.75f);
Line2H (hdc, 5, -5, 0.75f, 5, 5, 0.75f);
PenColor (hdc, VL_BROWN);
RLine2D (hdc, 2, 3, -5, -5);
break;
case IDM_2DPRIME_POLYLINE:
{
COORD poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
SetViewerName (VL_CURRENT, "2D PolyLines");
PenColor (hdc, VL_RED);
Polyline2D (hdc, VL_2D, poly, 4);
PushTransformation2D (NULL);
TranslateTo2D (3, 3);
ClosedPolyline2D (hdc, VL_2D, poly, 4);
TranslateTo2D (10, 0);
ClosedPolyline2D (hdc, VL_2D, poly, 4);
TranslateTo2D (10, -6);
ClosedPolyline2D (hdc, VL_2D, poly, 4);
TranslateTo2D (-10, -6);
ClosedPolyline2D (hdc, VL_2D, poly, 4);
TranslateTo2D (-10, 6);
ClosedPolyline2D (hdc, VL_2D, poly, 4);
PopTransformation2D (NULL);
LineTo2D (hdc, 0, 0);
break;
}
case IDM_2DPRIME_POINTER:
SetViewerName (VL_CURRENT, "2D Pointers");
PenColor (hdc, VL_YELLOW);
for (i = 0, a = 0; i < 12; i++, a += 0.5f) {
x = 9 * cos (a);
y = 5 * sin (a);
Pointer2D (hdc, 0, 0, (real) x, (real) y, 1, 0.5f, VL_CLOSEDARROW);
}
break;
case IDM_2DPRIME_MARK:
SetViewerName (VL_CURRENT, "2D Marks");
PenColor (hdc, VL_BLUE);
x = -9;
y = -6;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_CIRCLEMARK);
x += 2;
}
x = -9;
y = -4;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_CROSSMARK);
x += 2;
}
x = -9;
y = -2;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_XMARK);
x += 2;
}
x = -9;
y = 0;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_TRIANGLEMARK);
x += 2;
}
x = -9;
y = 2;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_BOXMARK);
x += 2;
}
x = -9;
y = 4;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_DIAMONDMARK);
x += 2;
}
x = -9;
y = 6;
for (i = 0; i < 10; i++) {
Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_HEXAGONMARK);
x += 2;
}
break;
case IDM_2DPRIME_LABEL:
SetViewerName (VL_CURRENT, "2D Labels");
TextColor (hdc, VL_RED, VL_WHITE, OPAQUE);
PenColor (hdc, VL_GREEN);
SetTextAlign (hdc, TA_CENTER | TA_BASELINE);
Label2D (hdc, 0, 0, "Center & BaseLine");
Mark2D (hdc, 0, 0, 15, 5, VL_CROSSMARK);
SetTextAlign (hdc, TA_CENTER | TA_TOP);
Label2D (hdc, 0, 3, "Center & Top");
Mark2D (hdc, 0, 3, 15, 3, VL_CROSSMARK);
SetTextAlign (hdc, TA_CENTER | TA_BOTTOM);
Label2D (hdc, 0, -3, "Center & Bottom");
Mark2D (hdc, 0, -3, 15, 3, VL_CROSSMARK);
SetTextAlign (hdc, TA_LEFT | TA_BASELINE);
Label2D (hdc, 3.5f, 0, "Left & BaseLine");
Mark2D (hdc, 3.5f, 0, 15, 5, VL_CROSSMARK);
SetTextAlign (hdc, TA_LEFT | TA_TOP);
Label2D (hdc, 3.5f, 3, "Left & Top");
Mark2D (hdc, 3.5f, 3, 15, 3, VL_CROSSMARK);
SetTextAlign (hdc, TA_LEFT | TA_BOTTOM);
Label2D (hdc, 3.5f, -3, "Left & Bottom");
Mark2D (hdc, 3.5f, -3, 15, 3, VL_CROSSMARK);
SetTextAlign (hdc, TA_RIGHT | TA_BASELINE);
Label2D (hdc, -3.5f, 0, "Right & BaseLine");
Mark2D (hdc, -3.5f, 0, 15, 5, VL_CROSSMARK);
SetTextAlign (hdc, TA_RIGHT | TA_TOP);
Label2D (hdc, -3.5f, 3, "Right & Top");
Mark2D (hdc, -3.5f, 3, 15, 3, VL_CROSSMARK);
SetTextAlign (hdc, TA_RIGHT | TA_BOTTOM);
Label2D (hdc, -3.5f, -3, "Right & Bottom");
Mark2D (hdc, -3.5f, -3, 15, 3, VL_CROSSMARK);
break;
case IDM_2DPRIME_ARROW:
SetViewerName (VL_CURRENT, "3D Arrows");
break;
case IDM_2DPRIME_NET:
{
COORD net[140];
short i, j, index = 0;
real x, y;
PenColor (hdc, VL_BLUE);
y = -6.5f;
for (i = 0; i < 7; i++) {
x = -9.5f;
for (j = 0; j < 10; j++) {
net[index++] = x + ((real) rand () / RAND_MAX);
net[index++] = y + ((real) rand () / RAND_MAX);
x += 2;
}
y += 2;
}
Net2D (hdc, VL_2D, (LPCOORD) net, 7, 10);
SetViewerName (VL_CURRENT, "2D Net");
break;
}
}
TextColor (hdc, VL_BLUE, VL_BLACK, TRANSPARENT);
DisplayViewerName (hdc, VL_CURRENT, FALSE);
}
VOIDED Prime3D (HDC hdc, int func)
{
PenColor (hdc, VL_WHITE);
DisplayViewerFrame (hdc, VL_CURRENT);
MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
switch (func) {
case IDM_3DPRIME_LINE:
SetViewerName (VL_CURRENT, "3D Lines");
PenColor (hdc, VL_RED);
MoveTo3D (hdc, 0, 0, 0);
LineTo3D (hdc, 10, 10, 0);
RLineTo3D (hdc, 0, -20, 0);
RLineTo3D (hdc, -20, 0, 0);
RLineTo3D (hdc, 0, 20, 0);
RLineTo3D (hdc, 20, 0, 0);
PenColor (hdc, VL_BLUE);
MoveTo3H (hdc, 1, 1, 0, 0.5f);
LineTo3H (hdc, 0, 1, 0, 0);
LineTo3H (hdc, 0, 0, 0, 1);
MoveTo3H (hdc, -1, 1, 0, 0.5f);
LineTo3H (hdc, -1, 0, 0, 0);
LineTo3H (hdc, 0, 0, 0, 1);
MoveTo3H (hdc, -1, -1, 0, 0.5f);
LineTo3H (hdc, 0, -1, 0, 0);
LineTo3H (hdc, 0, 0, 0, 1);
MoveTo3H (hdc, 1, -1, 0, 0.5f);
LineTo3H (hdc, 1, 0, 0, 0);
LineTo3H (hdc, 0, 0, 0, 1);
PenColor (hdc, VL_YELLOW);
MoveTo3D (hdc, 100, 100, 90);
LineTo3D (hdc, 10, 0, 0);
MoveTo3D (hdc, 100, 100, 90);
LineTo3D (hdc, 0, 10, 0);
MoveTo3D (hdc, 100, 100, 90);
LineTo3D (hdc, 0, 0, 10);
break;
case IDM_3DPRIME_POLYLINE:
{
COORD poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
SetViewerName (VL_CURRENT, "3D PolyLines");
PenColor (hdc, VL_RED);
Polyline3D (hdc, VL_2D, poly, 4);
PushTransformation3D (NULL);
Scale3D (5, 5, 5);
TranslateTo3D (3, 3, 0);
PenColor (hdc, VL_GREEN);
ClosedPolyline3D (hdc, VL_2D, poly, 4);
TranslateTo3D (10, 0, 0);
PenColor (hdc, VL_BLUE);
ClosedPolyline3D (hdc, VL_2D, poly, 4);
Translate